import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import shoppings from './modules/shoppings'
import getters from './getters'
import sales from './modules/sales'
import partners from './modules/partners'
import createVuexPersisted from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  },
  getters,
  mutations: {
  },
  actions: {
  },
  modules: {
    user,
    shoppings,
    sales,
    partners
  },
  plugins: [
    createVuexPersisted({
      // val就是根模块的state
      reducer (val) {
        // 指定存储某个模块的数据
        return {
          user: {
            token: val.user.token
          }
        }
      }
    })
  ]
})
